from building import *

objs = Glob("src/*.c") + Glob("src/*.cpp")

libsForSimulator = {
    "Can": Glob("src/config/Can_Cfg.c"),
    "Lin:as": Glob("src/config/Lin_Cfg.c"),
    "Dio": Glob("src/config/Dio*.c"),
    "Port": Glob("src/config/Port*.c"),
}


@register_library
class LibrarySimulator(Library):
    def config(self):
        if IsBuildForMSVC():
            self.LIBS = ["CanLib", "RS232", "Utils"]
        else:
            self.LIBS = ["CanLib", "DevLib", "Utils"]
        self.Append(CPPDEFINES=["LIN_USE_EXT_ID"])
        self.CPPPATH = ["$INFRAS", "$StdTrace_Cfg", "#RingBuffer"]
        self.source = objs
        for libName, cfg in libsForSimulator.items():
            self.LIBS += [libName]
            self.RegisterConfig(libName, cfg)
            self.CPPPATH += ["$%s_Cfg" % (libName)]
            self.Append(CPPDEFINES=["USE_%s" % (libName.split(":")[0].upper())])
        if IsBuildForMSVC():
            self.LIBS += ["User32"]


objsFlsAc = Glob("src/FlsAc.cpp") + Glob("src/critical.cpp")


@register_library
class LibraryFlsAc(Library):
    def config(self):
        self.CPPPATH = ["$INFRAS"]
        self.LIBS = ["Utils"]
        self.source = objsFlsAc


objsCritical = Glob("src/critical.cpp")


@register_library
class LibraryCritical(Library):
    def config(self):
        self.CPPPATH = ["$INFRAS"]
        self.source = objsCritical
